var g_game;
var g_canvas;

function MouseTracking(e)
{
    var left = e.pageX - Math.round(g_canvas.offsetLeft);
    var top = e.pageY - Math.round(g_canvas.offsetTop);
    g_game.mouseMoved(left, top);
}

function MouseClick(e)
{
    var left = e.pageX - Math.round(g_canvas.offsetLeft);
    var top = e.pageY - Math.round(g_canvas.offsetTop);
    g_game.mouseClicked(left, top);
}

function MouseOver(e)
{
    document.body.style.cursor.style='crosshair';
}

function MouseOut(e)
{
    document.body.style.cursor.style='default';
}

function GameUpdate()
{
	g_game.update();
	g_game.render();
}
var g_gui;
function DocReady()
{
    g_canvas = document.getElementById("gameCanvas");
    g_game = new Game(g_canvas);
    g_game.init(g_canvas);
    g_gui = new GameUI();
    g_gui.init(g_canvas);
    setInterval(GameUpdate, 1000/60);
    g_canvas.onmousemove=MouseTracking;
    g_canvas.onmouseup=MouseClick;
}

$(document).ready(DocReady);
